/**
 * <copyright>
 * </copyright>
 *
 * $Id$
 */
package ged.impl;

import ged.BorderInnerMargin;
import ged.BorderMargin;
import ged.Color;
import ged.Diagram;
import ged.Font;
import ged.GedPackage;
import ged.Label_attributes;
import ged.Layout;
import ged.LineType;
import ged.LineWidth;
import ged.Link;
import ged.Node;

import java.util.Collection;

import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;

import org.eclipse.emf.common.util.EList;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.impl.EObjectImpl;

import org.eclipse.emf.ecore.util.EObjectContainmentEList;
import org.eclipse.emf.ecore.util.InternalEList;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Diagram</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link ged.impl.DiagramImpl#getLayout <em>Layout</em>}</li>
 *   <li>{@link ged.impl.DiagramImpl#getNodes <em>Nodes</em>}</li>
 *   <li>{@link ged.impl.DiagramImpl#getLinks <em>Links</em>}</li>
 *   <li>{@link ged.impl.DiagramImpl#getColors <em>Colors</em>}</li>
 *   <li>{@link ged.impl.DiagramImpl#getMargin <em>Margin</em>}</li>
 *   <li>{@link ged.impl.DiagramImpl#getIn_margin <em>In margin</em>}</li>
 *   <li>{@link ged.impl.DiagramImpl#getWidth <em>Width</em>}</li>
 *   <li>{@link ged.impl.DiagramImpl#getFonts <em>Fonts</em>}</li>
 *   <li>{@link ged.impl.DiagramImpl#getL_attr <em>Lattr</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class DiagramImpl extends NodeImpl implements Diagram
{
  /**
   * The default value of the '{@link #getLayout() <em>Layout</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getLayout()
   * @generated
   * @ordered
   */
  protected static final String LAYOUT_EDEFAULT = null;

  /**
   * The cached value of the '{@link #getLayout() <em>Layout</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getLayout()
   * @generated
   * @ordered
   */
  protected String layout = LAYOUT_EDEFAULT;

  /**
   * The cached value of the '{@link #getNodes() <em>Nodes</em>}' containment reference list.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getNodes()
   * @generated
   * @ordered
   */
  protected EList<Node> nodes;

  /**
   * The cached value of the '{@link #getLinks() <em>Links</em>}' containment reference list.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getLinks()
   * @generated
   * @ordered
   */
  protected EList<Link> links;

  /**
   * The cached value of the '{@link #getColors() <em>Colors</em>}' containment reference list.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getColors()
   * @generated
   * @ordered
   */
  protected EList<Color> colors;

  /**
   * The cached value of the '{@link #getMargin() <em>Margin</em>}' containment reference list.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getMargin()
   * @generated
   * @ordered
   */
  protected EList<BorderMargin> margin;

  /**
   * The cached value of the '{@link #getIn_margin() <em>In margin</em>}' containment reference list.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getIn_margin()
   * @generated
   * @ordered
   */
  protected EList<BorderInnerMargin> in_margin;

  /**
   * The cached value of the '{@link #getWidth() <em>Width</em>}' containment reference list.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getWidth()
   * @generated
   * @ordered
   */
  protected EList<LineWidth> width;

  /**
   * The cached value of the '{@link #getFonts() <em>Fonts</em>}' containment reference list.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getFonts()
   * @generated
   * @ordered
   */
  protected EList<Font> fonts;

  /**
   * The cached value of the '{@link #getL_attr() <em>Lattr</em>}' containment reference list.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getL_attr()
   * @generated
   * @ordered
   */
  protected EList<Label_attributes> l_attr;

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  protected DiagramImpl()
  {
    super();
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  protected EClass eStaticClass()
  {
    return GedPackage.Literals.DIAGRAM;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public String getLayout()
  {
    return layout;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setLayout(String newLayout)
  {
    String oldLayout = layout;
    layout = newLayout;
    if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, GedPackage.DIAGRAM__LAYOUT, oldLayout, layout));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public EList<Node> getNodes()
  {
    if (nodes == null)
    {
      nodes = new EObjectContainmentEList<Node>(Node.class, this, GedPackage.DIAGRAM__NODES);
    }
    return nodes;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public EList<Link> getLinks()
  {
    if (links == null)
    {
      links = new EObjectContainmentEList<Link>(Link.class, this, GedPackage.DIAGRAM__LINKS);
    }
    return links;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public EList<Color> getColors()
  {
    if (colors == null)
    {
      colors = new EObjectContainmentEList<Color>(Color.class, this, GedPackage.DIAGRAM__COLORS);
    }
    return colors;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public EList<BorderMargin> getMargin()
  {
    if (margin == null)
    {
      margin = new EObjectContainmentEList<BorderMargin>(BorderMargin.class, this, GedPackage.DIAGRAM__MARGIN);
    }
    return margin;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public EList<BorderInnerMargin> getIn_margin()
  {
    if (in_margin == null)
    {
      in_margin = new EObjectContainmentEList<BorderInnerMargin>(BorderInnerMargin.class, this, GedPackage.DIAGRAM__IN_MARGIN);
    }
    return in_margin;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public EList<LineWidth> getWidth()
  {
    if (width == null)
    {
      width = new EObjectContainmentEList<LineWidth>(LineWidth.class, this, GedPackage.DIAGRAM__WIDTH);
    }
    return width;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public EList<Font> getFonts()
  {
    if (fonts == null)
    {
      fonts = new EObjectContainmentEList<Font>(Font.class, this, GedPackage.DIAGRAM__FONTS);
    }
    return fonts;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public EList<Label_attributes> getL_attr()
  {
    if (l_attr == null)
    {
      l_attr = new EObjectContainmentEList<Label_attributes>(Label_attributes.class, this, GedPackage.DIAGRAM__LATTR);
    }
    return l_attr;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs)
  {
    switch (featureID)
    {
      case GedPackage.DIAGRAM__NODES:
        return ((InternalEList<?>)getNodes()).basicRemove(otherEnd, msgs);
      case GedPackage.DIAGRAM__LINKS:
        return ((InternalEList<?>)getLinks()).basicRemove(otherEnd, msgs);
      case GedPackage.DIAGRAM__COLORS:
        return ((InternalEList<?>)getColors()).basicRemove(otherEnd, msgs);
      case GedPackage.DIAGRAM__MARGIN:
        return ((InternalEList<?>)getMargin()).basicRemove(otherEnd, msgs);
      case GedPackage.DIAGRAM__IN_MARGIN:
        return ((InternalEList<?>)getIn_margin()).basicRemove(otherEnd, msgs);
      case GedPackage.DIAGRAM__WIDTH:
        return ((InternalEList<?>)getWidth()).basicRemove(otherEnd, msgs);
      case GedPackage.DIAGRAM__FONTS:
        return ((InternalEList<?>)getFonts()).basicRemove(otherEnd, msgs);
      case GedPackage.DIAGRAM__LATTR:
        return ((InternalEList<?>)getL_attr()).basicRemove(otherEnd, msgs);
    }
    return super.eInverseRemove(otherEnd, featureID, msgs);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public Object eGet(int featureID, boolean resolve, boolean coreType)
  {
    switch (featureID)
    {
      case GedPackage.DIAGRAM__LAYOUT:
        return getLayout();
      case GedPackage.DIAGRAM__NODES:
        return getNodes();
      case GedPackage.DIAGRAM__LINKS:
        return getLinks();
      case GedPackage.DIAGRAM__COLORS:
        return getColors();
      case GedPackage.DIAGRAM__MARGIN:
        return getMargin();
      case GedPackage.DIAGRAM__IN_MARGIN:
        return getIn_margin();
      case GedPackage.DIAGRAM__WIDTH:
        return getWidth();
      case GedPackage.DIAGRAM__FONTS:
        return getFonts();
      case GedPackage.DIAGRAM__LATTR:
        return getL_attr();
    }
    return super.eGet(featureID, resolve, coreType);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @SuppressWarnings("unchecked")
  @Override
  public void eSet(int featureID, Object newValue)
  {
    switch (featureID)
    {
      case GedPackage.DIAGRAM__LAYOUT:
        setLayout((String)newValue);
        return;
      case GedPackage.DIAGRAM__NODES:
        getNodes().clear();
        getNodes().addAll((Collection<? extends Node>)newValue);
        return;
      case GedPackage.DIAGRAM__LINKS:
        getLinks().clear();
        getLinks().addAll((Collection<? extends Link>)newValue);
        return;
      case GedPackage.DIAGRAM__COLORS:
        getColors().clear();
        getColors().addAll((Collection<? extends Color>)newValue);
        return;
      case GedPackage.DIAGRAM__MARGIN:
        getMargin().clear();
        getMargin().addAll((Collection<? extends BorderMargin>)newValue);
        return;
      case GedPackage.DIAGRAM__IN_MARGIN:
        getIn_margin().clear();
        getIn_margin().addAll((Collection<? extends BorderInnerMargin>)newValue);
        return;
      case GedPackage.DIAGRAM__WIDTH:
        getWidth().clear();
        getWidth().addAll((Collection<? extends LineWidth>)newValue);
        return;
      case GedPackage.DIAGRAM__FONTS:
        getFonts().clear();
        getFonts().addAll((Collection<? extends Font>)newValue);
        return;
      case GedPackage.DIAGRAM__LATTR:
        getL_attr().clear();
        getL_attr().addAll((Collection<? extends Label_attributes>)newValue);
        return;
    }
    super.eSet(featureID, newValue);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public void eUnset(int featureID)
  {
    switch (featureID)
    {
      case GedPackage.DIAGRAM__LAYOUT:
        setLayout(LAYOUT_EDEFAULT);
        return;
      case GedPackage.DIAGRAM__NODES:
        getNodes().clear();
        return;
      case GedPackage.DIAGRAM__LINKS:
        getLinks().clear();
        return;
      case GedPackage.DIAGRAM__COLORS:
        getColors().clear();
        return;
      case GedPackage.DIAGRAM__MARGIN:
        getMargin().clear();
        return;
      case GedPackage.DIAGRAM__IN_MARGIN:
        getIn_margin().clear();
        return;
      case GedPackage.DIAGRAM__WIDTH:
        getWidth().clear();
        return;
      case GedPackage.DIAGRAM__FONTS:
        getFonts().clear();
        return;
      case GedPackage.DIAGRAM__LATTR:
        getL_attr().clear();
        return;
    }
    super.eUnset(featureID);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public boolean eIsSet(int featureID)
  {
    switch (featureID)
    {
      case GedPackage.DIAGRAM__LAYOUT:
        return LAYOUT_EDEFAULT == null ? layout != null : !LAYOUT_EDEFAULT.equals(layout);
      case GedPackage.DIAGRAM__NODES:
        return nodes != null && !nodes.isEmpty();
      case GedPackage.DIAGRAM__LINKS:
        return links != null && !links.isEmpty();
      case GedPackage.DIAGRAM__COLORS:
        return colors != null && !colors.isEmpty();
      case GedPackage.DIAGRAM__MARGIN:
        return margin != null && !margin.isEmpty();
      case GedPackage.DIAGRAM__IN_MARGIN:
        return in_margin != null && !in_margin.isEmpty();
      case GedPackage.DIAGRAM__WIDTH:
        return width != null && !width.isEmpty();
      case GedPackage.DIAGRAM__FONTS:
        return fonts != null && !fonts.isEmpty();
      case GedPackage.DIAGRAM__LATTR:
        return l_attr != null && !l_attr.isEmpty();
    }
    return super.eIsSet(featureID);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public String toString()
  {
    if (eIsProxy()) return super.toString();

    StringBuffer result = new StringBuffer(super.toString());
    result.append(" (layout: ");
    result.append(layout);
    result.append(')');
    return result.toString();
  }

} //DiagramImpl
